// tslint:disable-next-line:no-var-requires
const config: {[propName: string]: {[propName: string]: string}} = require('../../config');

/**
 * 配置类，获取配置信息
 */
export class BuildParam {
  [propName: string]: string;
  public authTokenKeyName!: string;
  public publicPath!: string;
  public tokenKey!: string;
  public nodeEnv!: string;
  public apiUrl!: string;
}

let envConfig: any;
const nodeEnv: string | undefined = process.env.NODE_ENV;
if (nodeEnv !== undefined && config[process.env.NODE_ENV as string] !== undefined) {
  envConfig = config[process.env.NODE_ENV as string] || config.default;
}
const buildConfig = new BuildParam();
buildConfig.authTokenKeyName = envConfig.authTokenKeyName;
buildConfig.useProxyUrl = envConfig.useProxyUrl;
buildConfig.publicPath = envConfig.publicPath;
buildConfig.tokenKey = envConfig.tokenKey;
buildConfig.apiUrl = nodeEnv === 'production' ? envConfig.apiRealUrl : envConfig.useProxyUrl;
buildConfig.nodeEnv = process.env.NODE_ENV as string;
export default buildConfig;
